/*******************************************************************************
 * Simple C-K Editor
 * 
 * Copyright (C) 2009 Ingi BROWN - Centre de Gestion Scientifique - Ecole des Mines ParisTech
 * Licensed under the GNU General Public License Version 3.
 * 
 * Simple C-K Editor includes source code and libraries from the JUNG Project (Java Universal Network/Graph Framework) 
 * released under the BSD license. Copyright (c) 2003-2004,  Regents of the University of California and the JUNG Project.
 * 
 * See the License.txt file for more details.
 ******************************************************************************/

package edu.ensmp.ckEditor.ckModel;

import java.awt.Color;
import java.awt.Point;
import java.util.Vector;


/**
 * Defines concept and knowledge classes - used by JUNG as vertices of the
 * graphs For the moment, Concepts and Knowledge are defined identically, with 2
 * private variables: an index and a proposition. This will evolve in the
 * future, as the need for a more precise implementation of the C-K Theory will
 * be needed.
 */
public class CKModel {
	

	public static Vector<Concept> vecConceptSave = new Vector<Concept>();
	public static Vector<Concept> getVecConceptSave() {
		return vecConceptSave;
	}

	public static Vector<Knowledge> getVecKnowledgeSave() {
		return vecKnowledgeSave;
	}

	public static Vector<Edge> getVecEdgeSave() {
		return vecEdgeSave;
	}

	public static Vector<Knowledge> vecKnowledgeSave = new Vector<Knowledge>();
	public static Vector<Edge> vecEdgeSave = new Vector<Edge>();
	
	private int indiceC = 0;
	private int indiceK = 0;
	
	/** Creates a new instance of CKModel */
	public CKModel() {
	}

	public void setIndiceC(int indiceC) {
		this.indiceC = indiceC;
	}

	public int getIndiceC() {
		return indiceC;
	}

	public void setIndiceK(int indiceK) {
		this.indiceK = indiceK;
	}

	public int getIndiceK() {
		return indiceK;
	}

	/** Concept class */
	public static class Concept{
		private int index;
		private String proposition;
		private Point position;
		private Color color;

		/**
		 * Constructors
		 * 
		 * @param id
		 * @param proposition
		 */
		public Concept() {
		}
		
		public Concept(int id) {
			this.index = id;
			this.proposition = null;
			this.color = Color.BLACK;
		}
		
		public Concept(int id, String proposition) {
			this.index = id;
			this.proposition = proposition;
			this.color = Color.BLACK;

		}
		
		public Concept(int id, String proposition, Point position) {
			this.index = id;
			this.proposition = proposition;
			this.position = position;
			this.color = Color.BLACK;

		}
		
		public Concept(int id, String proposition, Point position, Color color) {
			this.index = id;
			this.proposition = proposition;
			this.position = position;
			this.color = color;

		}

		/** Getters and Setters */
		public int getIndex() {
			return index;
		}

		public void setIndex(int index) {
			this.index = index;
		}

		public String getProposition() {
			return this.proposition;
		}

		public void setProposition(String proposition) {
			this.proposition = proposition;
		}
		
		public void setPosition(Point posSouris){
			this.position = posSouris;
		}
		
		public int getPositionX() {
			return (int) this.position.getX();
		}
		
		public int getPositionY(){
			return (int) this.position.getY();
		}
		
		public Point getPosition(){
			return this.position;
		}

		/** toString method - widely used with JUNG */
		
		public String toString() {
			return "C" + index + "-" + proposition;
		}
		
		public void setVecteurConceptSave(){
			vecConceptSave.add(this);
		}
		
		public Concept getVecteurConceptSave(int i){
			return vecConceptSave.elementAt(i);
		}

		/**
		 * @param color the color to set
		 */
		public void setColor(Color color) {
			this.color = color;
		}

		/**
		 * @return the color
		 */
		public Color getColor() {
			return color;
		}
		
		
	}

	/** Knowledge class */
	public static class Knowledge {
		private int index;
		private String proposition;
		private Point position;

		/**
		 * Constructors
		 * 
		 * @param id
		 * @param proposition
		 */
		public Knowledge() {
		}
		
		public Knowledge(int id) {
			this.index = id;
			this.proposition = null;
		}

		public Knowledge(int id, String proposition) {
			this.index = id;
			this.proposition = proposition;
		}
		
		public Knowledge(int id, String proposition, Point position) {
			this.index = id;
			this.proposition = proposition;
			this.position = position;
		}

		/** Getters and Setters */
		public int getIndex() {
			return index;
		}

		public void setIndex(int index) {
			this.index = index;
		}

		public String getProposition() {
			return this.proposition;
		}

		public void setProposition(String proposition) {
			this.proposition = proposition;
		}

		public void setPosition(Point position) {
			this.position = position;
		}


		public int getPositionX() {
			return (int) position.getX();
		}
		
		public int getPositionY(){
			return (int) position.getY();
		}
		
		public Point getPosition(){
			return this.position;
		}
		
		public void setVecteurKnowledgeSave(){
			vecKnowledgeSave.add(this);
		}
		
		public Knowledge getVecteurKnowledgeSave(int i){
			return vecKnowledgeSave.elementAt(i);
		}

		/** toString method - widely used with JUNG */
	
		public String toString() {
			return "K" + index + "-" + proposition;
		}
	}

	/**
	 * The Partition class is used for the Edges in Concept Graphs. The
	 * Partition class is *very* poor for the moment, for we do not need any
	 * precise implementation. A future evolution of this code will implement
	 * Partitions more precisely by adding interesting attributes.
	 */
	public static class Edge{// Partition {
		
		private int index;
		private int indiceDebut;
		private int indiceFin;
		
		public Edge(){
			
		}
		public Edge(int index){
			this.setIndex(index);
		}
		
		public Edge(int index, int indiceDeb, int indiceFin){
			this.setIndiceDebut(indiceDeb);
			this.setIndiceFin(indiceFin);
		}
		/**
		 * @param index the index to set
		 */
		public void setIndex(int index) {
			this.index = index;
		}
		/**
		 * @return the index
		 */
		public int getIndex() {
			return index;
		}
		/**
		 * @param indiceDebut the indiceDebut to set
		 */
		public void setIndiceDebut(int indiceDebut) {
			this.indiceDebut = indiceDebut;
		}
		/**
		 * @return the indiceDebut
		 */
		public int getIndiceDebut() {
			return indiceDebut;
		}
		/**
		 * @param indiceFin the indiceFin to set
		 */
		public void setIndiceFin(int indiceFin) {
			this.indiceFin = indiceFin;
		}
		/**
		 * @return the indiceFin
		 */
		public int getIndiceFin() {
			return indiceFin;
		}
		
		public void setVecEdgeSave(){
			vecEdgeSave.add(this);
		}
		
		public Edge getVecEdgeSave(int i){
			return vecEdgeSave.elementAt(i);
		}
		
		
		
		

	}

	/**
	 * The KnowledgeLink class is used for the Edges in Knowledge Graphs. The
	 * KnowledgeLink class is *very* poor for the moment, for we do not need any
	 * precise implementation. A future evolution of this code will implement
	 * KnowledgeLink more precisely by adding interesting attributes.
	 */
	public static class KnowledgeLink {

	}

}
